package com.bonjour.work.controller.api;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.bonjour.common.core.RpcReply;
import com.bonjour.work.dto.request.user.UpdatePwdReq;
import com.bonjour.work.dto.request.user.UpdateUserReq;
import com.bonjour.work.entity.UserEntity;
import com.bonjour.work.service.UserService;

import javax.inject.Inject;

@RestController
@RequestMapping("/user")
public class UserController {

    private UserService userService;

    @Inject
    public UserController(UserService userService) {
        this.userService = userService;
    }


    /**
     * 获取用户登录信息
     *
     * @return
     */
    @GetMapping("/getUserMsg")
    public RpcReply<UserEntity> getUserMsg() {
        return userService.getUserMsg();
    }

    /**
     * 修改密码
     *
     * @return
     */
    @PostMapping("/updatePwd")
    public RpcReply<Void> updatePwd(@RequestBody @Validated UpdatePwdReq pwdReq) {
        return userService.updatePwd(pwdReq);
    }
    
    /**
     * 更新用户状态
     *
     * @param listReq
     * @return
     */
    @PostMapping("/updateUserStatus")
    public RpcReply<Void> updateUserStatus(@RequestBody UpdateUserReq listReq) {
        return userService.updateUserStatus(listReq);
    }

}
